package com.bjesc_b2c.app.appraiset.adapter;

import android.content.Context;
import android.text.TextUtils;

import com.bjesc_b2c.app.appraiset.R;

import java.util.List;

import app.pinggushi.bjesc.com.baserecyclerview.adapter.CommonAdapter;
import app.pinggushi.bjesc.com.baserecyclerview.adapter.base.ViewHolder;
import master_bean.CarForBean;

/**
 * Created by yidong on 2017/10/19.
 */

public class InventoryAdapter extends CommonAdapter<CarForBean> {

    public InventoryAdapter(Context context, int layoutId, List<CarForBean> datas) {
        super(context, layoutId, datas);
    }
    @Override
    protected void convertView(ViewHolder holder, CarForBean bean, int position) {
            holder.setText(R.id.tv_dealer_name, bean.getName()+"(维护人："+bean.getBusiness_agent()+")");
            if (TextUtils.isEmpty(bean.getAddress())){
                holder.setVisible(R.id.tv_dealer_address,false);
            }else {
                holder.setText(R.id.tv_dealer_address, bean.getAddress());
            }
            if (TextUtils.isEmpty(bean.getBoss()) && TextUtils.isEmpty(bean.getPhone()) ){
                holder.setVisible(R.id.tv_name_phone,false);
            }else {
                holder.setText(R.id.tv_name_phone, bean.getBoss() +" "+bean.getPhone());
            }
            if (TextUtils.isEmpty(bean.getInventory_time())){
                holder.setVisible(R.id.tv_check_type,false);
            }else {
                holder.setVisible(R.id.tv_check_type,true);
//             1，今日已盘库；2，盘库时间：2017-02-32；3，超期未盘库；4，未盘库
                if (bean.getType() ==1){
                    holder.setTextColorRes(R.id.tv_check_type,R.color.color35B247);
                }else if(bean.getType() ==2){
                    holder.setTextColorRes(R.id.tv_check_type,R.color.colorFF28AFE1);
                }else {
                    holder.setTextColorRes(R.id.tv_check_type,R.color.colorFFF7041B);
                }
                holder.setText(R.id.tv_check_type, bean.getInventory_time());
            }
    }

}
